package com.pinda.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.pinda.work.entity.PdTransportOrder;
import com.pinda.mapper.PdTransportOrderMapper;
import com.pinda.service.IPdTransportOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 运单表 服务实现类
 * </p>
 *
 * @author lc
 * @since 2023-06-14
 */
@Service
public class PdTransportOrderServiceImpl extends ServiceImpl<PdTransportOrderMapper, PdTransportOrder> implements IPdTransportOrderService {

    @Resource
    PdTransportOrderMapper pdTransportOrderMapper;

    @Override
    public boolean TransportOrderUpdate(PdTransportOrder pdTransportOrder) {

        int update = pdTransportOrderMapper.updateById(pdTransportOrder);
        return update != 0;
    }

    @Override
    public Boolean savePdTransportOrder(PdTransportOrder pdTransportOrder) {
        return pdTransportOrderMapper.savePdTransportOrder(pdTransportOrder);
    }

    @Override
    public PdTransportOrder selectById(String id) {

        return pdTransportOrderMapper.selectById(id);
    }

    /**
     * 根据订单id,修改状态为已签收
     *
     * @param id
     */
    @Override
    public void UpdTransportOrder(String id) {
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.eq("order_id", id);
        updateWrapper.setSql("status=5");
        pdTransportOrderMapper.update(null, updateWrapper);
    }

    @Override
    public PdTransportOrder findByOrderId(String orderId) {
        return getOne(new LambdaQueryWrapper<PdTransportOrder>().eq(PdTransportOrder::getOrderId, orderId));
    }
}
